from django.shortcuts import render, HttpResponse


# 在url中携带参数
# 1. 通过查询字符串传递参数：http://localhost:8000/books/?author=John&title=The
# 3. 通过表单传递参数：http://localhost:8000/books/search/

# 1. 通过查询字符串传递参数
# http://localhost:8000/books/?name=The+Great+Gatsby&author=F.Scott Fitzgerald
def book1(request):
    book_name = request.GET.get('name')  # 获取查询字符串参数
    author = request.GET.get('author')
    return HttpResponse(f"Book name: {book_name}, Author: {author}")

# http://localhost:8000/books/1/


def book2(request, book_id):
    return HttpResponse(f"Book ID: {book_id}")


def book_str(request, book_str):
    return HttpResponse(f"Book String: {book_str}")


def book_slug(request, book_slug):
    return HttpResponse(f"Book Slug: {book_slug}")


def book_path(request, book_path):
    return HttpResponse(f"Book Path: {book_path}")